﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Core.StyleAndResource
{
    /// <summary>
    /// DynamicResource.xaml 的交互逻辑
    /// </summary>
    public partial class DynamicResourceDemo : Window
    {
        public DynamicResourceDemo()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //清除资源
            myContainer.Resources.Clear();

            var brush = new LinearGradientBrush
            {
                StartPoint = new Point(1, 0),
                EndPoint = new Point(0, 1)
            };
            brush.GradientStops = new GradientStopCollection()
            {
                new GradientStop(Colors.White,0),
                new GradientStop(Colors.Yellow,0.5),
                new GradientStop(Colors.Blue,1)
            };

            myContainer.Resources.Add("MyGradientBrush", brush);
        }
    }
}
